#ifndef _DOUBLELINKLIST_H_
#define _DOUBLELINKLIST_H_

#define ElementType int 

class DoubleLinkList
{
public:
    DoubleLinkList();
    ~DoubleLinkList();

    //增删改查
    //排序 二分
    void InsertTail(ElementType element);
    void InsertHead(ElementType element);
    void InsertByIndex(int index,ElementType element);
    //按位置删除
    void RemoveByIndex(int index);
    //按值删除
    void RemoveByElement(ElementType element);
    //修改位置上的值
    void UpdateByIndex(int index,ElementType newValue);
    //按值修改
    void UpdateByElement(ElementType oldValue,ElementType newValue);
    //按位置查找值
    ElementType& operator[](int index);
    void BubbleSort();
    void FastSort();
    //归并
    DoubleLinkList Merge(const DoubleLinkList& l);
    //二分查找
    int BinarySearch(ElementType element);
    void show();
    void ReserveShow();
    void Reserve();
    void Reserve2();
    int getSize();
private:
    struct Node
    {
        ElementType data;
        Node *prev;
        Node* next;
    };
    Node *GetEnd();
    Node *CreateNode(ElementType element);
    void FastSort(Node *start,Node *end);
    Node* Reserve2(Node *node);
    Node *head;
    Node *m_tail;
    int size;
};

using DLlist = DoubleLinkList;






#endif